'use strict';

/**
 * @ngdoc function
 * @name interviewDemoApp.controller:LoginCtrl
 * @description
 * # LoginCtrl
 * Controller of the interviewDemoApp
 */
angular.module('interviewDemoApp')
  .controller('LoginCtrl', function ($scope, $http, $state) {
  	$scope.user = {
  		username: '',
  		password: ''
  	}
  	$scope.login_submit = function() {
  		$http({
		url:'/users',
		method:'GET',
		params: {
			username: $scope.user.username,
			password: $scope.user.password
		}
		}).success(function(data,header,config,status){
			if(data.code === '1001' || data.code === 1001) {

			} else if(data.code === '1002' || data.code === 1002) {

			} else if(data.code === '1000' || data.code === 1000){
				$state.go('resume');
			}
		}).error(function(data,header,config,status){
			console.log(data);
		});
  	}
  });
